import Vue from 'vue'
import Vuex from 'vuex'
import app from './modules/app'
import asset from './modules/asset'
import assetStock from './modules/assetStock'
import developerConsole from "@/store/modules/developerConsole"

Vue.use(Vuex)

// https://webpack.js.org/guides/dependency-management/#requirecontext
let modulesFiles = require.context('./modules', false, /\.ts$/)
const modules = modulesFiles.keys().reduce((modules, modulePath) => {
  // set './app.js' => 'app'
  const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
  const value = modulesFiles(modulePath)
  modules[moduleName] = value.default
  return modules
}, {})

const store = new Vuex.Store({
  modules
})

export default store